﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<GabageFactory.Models.EventRecordDetail>" %>
<%@ Import Namespace="System.Collections.Generic" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	事件详情
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <script type="text/javascript">
        function setCenter(Xelement) {
            var parent = Xelement.parentNode;
//            parent.style.position = "relative";
//            Xelement.style.position = "absolute";
//            var left = (parent.clientWidth - Xelement.clientWidth) / 2;
//            var top = (parent.clientHeight - Xelement.clientHeight) / 2;
//            Xelement.style.left = left + "px";
//            Xelement.style.top = top + "px";
        }
    </script>
    
    <% 
        User user = (User)ViewData["user"];
        User recorder = (User)ViewData["recorder"];
        EventDailyRecord dailyRecord = (EventDailyRecord) ViewData["dailyRecord"];
        EventDailyRecord firstRecord = (EventDailyRecord)ViewData["firstRecord"];
        EventDailyRecord lastRecord = (EventDailyRecord)ViewData["lastRecord"];
        long preDailyId = (long)ViewData["preDailyId"];
        long nextDailyId = (long)ViewData["nextDailyId"];
        string[] types = (string[])ViewData["types"];
        string[] priorities = (string[])ViewData["priorites"];
    %>
    
    <h3>事件详情</h3>

    <table cellpadding="3" cellspacing="0" class="com_from_table2" style="width:756px;">
        <tr>
            <td class="lab" style="width:12%;font-weight:bold;">记录时间：</td>
            <td style="width:38%;"><%=dailyRecord.OccurredDate.ToString("yyyy-MM-dd HH:mm")%></td>
            <td style=" text-align:right; width:12%;font-weight:bold;">上报人：</td>
            <td style="width:38%;"><%=Model.UserName%></td>
        </tr>
        <tr>
            <td class="lab" style="font-weight:bold;">事件现场：</td>
            <td colspan="3"><%=Model.StackName %></td>
        </tr>
        <tr>
            <td class="lab" style="font-weight:bold;">事件名称：</td>
            <td colspan="3"><%=Model.Name%></td>
        </tr>
        <tr>
            <td class="lab" style="font-weight:bold;">事件级别：</td>
            <td><%=priorities[Model.Priority] %></td>
            <td class="lab" style="font-weight:bold;">事件类别：</td>
            <td><%=types[Model.Type] %></td>
        </tr>
        <tr>
            <td class="lab" style="font-weight:bold;">事件描述：</td>
            <td colspan="3"><%=firstRecord.Description%></td>
        </tr>
        <tr>
            <td class="lab" style="font-weight:bold;">事件总结：</td>
            <td colspan="3"><%= Model.Status == 2 ? (string.IsNullOrEmpty(lastRecord.Description) ? "（监控负责人未填写事件总结）" : lastRecord.Description) : (Model.Status == 1 ? "（事件待确认结束）" : "（事件正在处理中）")%></td>
        </tr>
    </table>

    <table cellpadding="3" cellspacing="0" class="com_from_table2" style="margin-top:4px; width:756px; table-layout:fixed;">
        <tr>
            <th style="width:68%;">
                
                <span style="margin-right:2em;"><% if (preDailyId > 0) { %><%=Html.ActionLink("前一天", "Detail", new { eventId = Model.Id, dailyId = preDailyId })%><%}else { %>前一天<%} %></span>
                <span>
                    第<%= ((dailyRecord.OccurredDate.Date - Model.OccurredDate.Date).Days + 1)%> 天(<%=dailyRecord.OccurredDate.Date.ToString("yyyy-MM-dd")%>)
                </span>
                <span style="margin-left:2em;"><% if (nextDailyId > 0) { %><%=Html.ActionLink("后一天", "Detail", new { eventId = Model.Id, dailyId = nextDailyId })%><%}else { %>后一天<%} %></span>
                <span style="margin-left:2em;">当日进度：<%=dailyRecord.Progress %>%</span>
            </th>
            <th style="text-align:right; width:12%;">记录人：</th>
            <th style="width:20%;"><%=recorder.RealName + "(" + recorder.Name + ")" %></th>
        </tr>
        <%if (preDailyId > 0) { %>
        <tr>
            <td colspan="3" style="padding:5px 12px;"><%=dailyRecord.Description%></td>
        </tr>
        <%} %>
        <tr>
            <td colspan="2" style="padding:10px 0; text-align:center; height:480px; background-color:#efefef;">
                <div style=" margin:5px 12px; padding:10px; vertical-align:middle; border:2px solid #e4e4e4; background:#fff;">
                <img id="currentImg" onclick="showPicInNewWindow();" src="<% if (!string.IsNullOrEmpty(dailyRecord.Pic1)) {%><%=Url.Content(dailyRecord.Pic1) %><%}else {%>../../Content/empty.png<%} %>" alt="" title="新窗口打开大图" onload="setCenter(this)" class="thumbnailbig" />
                </div>
                <div style="margin:0 2em 0 2em; text-align:left; text-indent:2em;">
                    <span id="currentDesc"><%= dailyRecord.Pic1_desc%></span>
                </div>
            </td>
            <td id="pics" class="tb_thumb_area">
                <div <% if (!string.IsNullOrEmpty(dailyRecord.Pic1)) {%>onclick="changePic(1);"<%} %>><img id="pic1" src="<% if (string.IsNullOrEmpty(dailyRecord.Pic1)) {%>../../Content/empty.png<%}else{ %><%=Url.Content(dailyRecord.Pic1) %><%} %>" alt="" onload="setCenter(this)" class="img_thumb" /></div>
                <div style="display:none" id="picDesc1"><%= dailyRecord.Pic1_desc%></div>
                
                <div <% if (!string.IsNullOrEmpty(dailyRecord.Pic2)) {%>onclick="changePic(2);"<%} %>><img id="pic2" src="<% if (string.IsNullOrEmpty(dailyRecord.Pic2)) {%>../../Content/empty.png<%}else{ %><%=Url.Content(dailyRecord.Pic2) %><%} %>" alt="" onload="setCenter(this)" class="<% if (string.IsNullOrEmpty(dailyRecord.Pic2)) {%>hide<%}else{ %>img_thumb<%} %>" /></div>
                <div style="display:none" id="picDesc2"><%= dailyRecord.Pic2_desc%></div>

                <div <% if (!string.IsNullOrEmpty(dailyRecord.Pic3)) {%>onclick="changePic(3);"<%} %>><img id="pic3" src="<% if (string.IsNullOrEmpty(dailyRecord.Pic3)) {%>../../Content/empty.png<%}else{ %><%=Url.Content(dailyRecord.Pic3) %><%} %>" alt="" onload="setCenter(this)" class="<% if (string.IsNullOrEmpty(dailyRecord.Pic2)) {%>hide<%}else{ %>img_thumb<%} %>" /></div>
                <div style="display:none" id="picDesc3"><%= dailyRecord.Pic3_desc%></div>

                <div <% if (!string.IsNullOrEmpty(dailyRecord.Pic4)) {%>onclick="changePic(4);"<%} %>><img id="pic4" src="<% if (string.IsNullOrEmpty(dailyRecord.Pic4)) {%>../../Content/empty.png<%}else{ %><%=Url.Content(dailyRecord.Pic4) %><%} %>" alt="" onload="setCenter(this)" class="<% if (string.IsNullOrEmpty(dailyRecord.Pic2)) {%>hide<%}else{ %>img_thumb<%} %>" /></div>
                <div style="display:none" id="picDesc4"><%= dailyRecord.Pic4_desc%></div>
           </td>
        </tr>
    </table>

 <%--   <table cellpadding="4" cellspacing="0" class="com_detail_table" style=" width:956px;">
        <tr>
            <th colspan="8">事件详情</th>
        </tr>
        <tr>
            <td>事件名称:</td>
            <td colspan="7"><%=Model.Name%></td>
        </tr>
        <tr>
            <td>事件现场：</td>
            <td colspan="7">
                <%=Model.StackName %>
            </td>
        </tr>
        <tr>
            <td>记录时间:</td>
            <td><%=dailyRecord.OccurredDate.ToString("yyyy-MM-dd HH:mm")%></td>
            <td>事件类别：</td>
            <td><%=types[Model.Type] %></td>
            <td>事件级别</td>
            <td><%=priorities[Model.Priority] %></td>
            <td>上报人</td>
            <td><%=Model.UserName%></td>
        </tr>
        <tr>
            <td>事件描述：</td>
            <td colspan="7"><%=firstRecord.Description%></td>
        </tr>
        <tr>
            <td>事件总结：</td>
            <td colspan="7"><%= Model.Status == 2 ? lastRecord.Description : ""%></td>
        </tr>
        <tr>
            <td colspan="7">
                <span>第<%= ((dailyRecord.OccurredDate.Date - Model.OccurredDate.Date).Days + 1)%> 天(<%=dailyRecord.OccurredDate.Date.ToString("yyyy-MM-dd")%>)</span>
                <span style="margin-left:15px"><% if (preDailyId > 0) { %><%=Html.ActionLink("前一天", "Detail", new { eventId = Model.Id, dailyId = preDailyId })%><%}else { %>前一天<%} %></span>
                <span style="margin-left:15px"><% if (nextDailyId > 0) { %><%=Html.ActionLink("后一天", "Detail", new { eventId = Model.Id, dailyId = nextDailyId })%><%}else { %>后一天<%} %></span>
            </td>
            <td>&nbsp</td>
        </tr>
        <tr>
            <td colspan="7">记录人：<%=recorder.RealName + "(" + recorder.Name + ")" %><span style="margin-left:15px">当日进度：<%=dailyRecord.Progress %>%</span></td>
            <td>&nbsp;</td>
        </tr>
        <%if (preDailyId > 0) { %>
        <tr>
            <td colspan="8"><%=dailyRecord.Description%></td>
        </tr>
        <%} %>
        <tr>
           <td colspan="7">
               <div style="width:600px;height:450px;">
                   <img id="_currentImg" onclick="showPicInNewWindow();" src="<% if (!string.IsNullOrEmpty(dailyRecord.Pic1)) {%><%=Url.Content(dailyRecord.Pic1) %><%}else {%>../../Content/empty.png<%} %>" alt="" onload="setCenter(this)" class="thumbnailbig" />
               </div>
               <div></div>
           </td>
           
        </tr>
    </table>--%>
    
    <div style="margin-top:15px">
        <input type="button" value="返回该事件跟踪列表" onclick="gotoTrack();" />
    </div>

    <script type="text/javascript">
        function changePic(index) {
            $("#currentImg").attr("src", $("#pic" + index).attr("src"));
            $("#currentDesc").text($("#picDesc" + index).text());
            setCenter(document.getElementById("currentImg"));
        }

        function showPicInNewWindow() {
            window.open($("#currentImg").attr("src"));
        }
	
	function gotoTrack() {
	    document.location.href = '<%=Url.Content("~/Event/Track?eventId=" + Model.Id)%>';
	}
    </script>
</asp:Content>
